import React from "react";
import { createBrowserRouter } from "react-router-dom";
import { lazy, Suspense } from "react";

// 路由配置
import Layout from "../pages/layout/Layout.jsx";
import Home from "../pages/home/Home.jsx";
// import Login from "../pages/layout";
//import CityList from "../page/CityList/cityList";
import Login from "../pages/login/Login.jsx";
import Manager from "../pages/manager/Manager.jsx";
import UserCenter from "../pages/person/UserCenter.jsx";

// 1. lazy函数对组件进行导入--路由懒加载
// const Home = lazy(() => import('../pages/home/Home.jsx'))
// const HomeList = lazy(() => import('../page/HomeList/index'))
// const News = lazy(() => import('../page/News/index'))
// const Profile = lazy(() => import('../page/Profile/index'))
// const Map = lazy(() => import('../page/Map/map'))

// 配置路由实例
const router = createBrowserRouter([
    {
        path: '/',
        element: <Layout></Layout>,
        children: [
            {
                // 设置默认二级路由
                index: true,
                // path: 'home',
                element: <Home />
            },
            {
                // 设置默认二级路由
                path: 'home',
                element: <Home />
            },
            // {
            //     path: '/home/list',
            //     element: <Suspense fallback={<div>Loading...</div>}><HomeList /></Suspense>
            // },
            {
                path: 'manager',
                element: <Suspense fallback={<div>Loading...</div>}><Manager /></Suspense>
            },
            {
                path: 'userCenter',
                element: <Suspense fallback={<div>Loading...</div>}><UserCenter /></Suspense>
            },
        ]
    },
    {
        path: '/login',
        element: <Login />
    },
    // {
    //     path: '/map',
    //     element: <Map />
    // },
    // {
    //   path: '*',
    //   element: <NotFound />
    // },

], {
    future: {
        v7_startTransition: true, // 启用 v7_startTransition 标志
        v7_relativeSplatPath: true,
        v7_skipActionErrorRevalidation: true,
        v7_partialHydration: true,
    }
})
// ], {
//     future: {
//         v7_relativeSplatPath: true,
//             v7_startTransition: true,
//             v7_skipActionErrorRevalidation: true,
//             v7_partialHydration: true,
//     }
// })

export default router